package fragments.shopadapter;

import android.content.Context;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.travel.R;

import java.util.List;

import shopbean.PageBean;
import shopbean.ShopBean;

/**
 * 商城模块 热卖商品
 * Created by Administrator on 2016/10/18.
 */
public class ShopListViewAdapter extends BaseAdapter {
    private Context context;
    private List<PageBean.DataBean.LineBean> mListBeen;

    public ShopListViewAdapter(Context context, List<PageBean.DataBean.LineBean> mListBeen) {
        this.context = context;
        this.mListBeen = mListBeen;
    }

    @Override
    public int getCount() {
        return mListBeen.size();
    }

    @Override
    public Object getItem(int i) {
        return mListBeen.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder mHolder;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.shop_listview_item,viewGroup,false);
            mHolder=new ViewHolder();
            mHolder.shop_lv_iv= (ImageView) view.findViewById(R.id.shop_lv_iv);
            mHolder.shop_lv_title= (TextView) view.findViewById(R.id.shop_lv_title);
            mHolder.shop_lv_price= (TextView) view.findViewById(R.id.shop_lv_price);
            mHolder.shop_lv_tocity= (TextView) view.findViewById(R.id.shop_lv_tocity);
            view.setTag(mHolder);
        }else{
            mHolder= (ViewHolder) view.getTag();
        }
        mHolder.shop_lv_title.setText(mListBeen.get(i).getTitle());
        mHolder.shop_lv_price.setText(""+mListBeen.get(i).getPrice());
        mHolder.shop_lv_tocity.setText(mListBeen.get(i).getToCity());
        Glide.with(context).load(mListBeen.get(i).getThumbPath()).placeholder(R.mipmap.default_square_large).into(mHolder.shop_lv_iv);
        return view;
    }
    static  class ViewHolder{
        ImageView shop_lv_iv;
        TextView shop_lv_title,shop_lv_price,shop_lv_tocity;
    }
}
